﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
using System.Drawing.Imaging;
using System.Data;
using System.IO;
using System.Text;
using System.Runtime.InteropServices;
namespace Web
{
    public partial class ps : System.Web.UI.Page
    {
       
        protected void Page_Load(object sender, EventArgs e)
        {
            TextBox1.Visible = false;
            //Image1.ImageUrl = "D://demo.jpg";

        }

        protected void Search_Click(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Bitmap bitmap = new Bitmap(Server.MapPath("~/Img/")+TextBox1.Text);
            PS ps = new PS();
            Bitmap newBitmap = ps.fun1(bitmap.Height, bitmap.Width, bitmap);

            String fileName = DateTime.Now.ToString("yyyyMMddhhmmss") + "1.jpg";
            newBitmap.Save(Server.MapPath("~/Img/" + fileName), ImageFormat.Jpeg);
            Image2.ImageUrl = "~/Img/" + fileName;
           // TextBox1.Text = "~/image/" + fileName;
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            Bitmap bitmap = new Bitmap(Server.MapPath("~/Img/") + TextBox1.Text);
            PS ps = new PS();
            Bitmap newBitmap = ps.fun2(bitmap.Height, bitmap.Width, bitmap);

            String fileName = DateTime.Now.ToString("yyyyMMddhhmmss") + "2.jpg";
            newBitmap.Save(Server.MapPath("~/Img/" + fileName), ImageFormat.Jpeg);
            Image2.ImageUrl = "~/Img/" + fileName;
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            Bitmap bitmap = new Bitmap(Server.MapPath("~/Img/") + TextBox1.Text);
            PS ps = new PS();
            Bitmap newBitmap = ps.fun3(bitmap.Height, bitmap.Width, bitmap);

            String fileName = DateTime.Now.ToString("yyyyMMddhhmmss") + "3.jpg";
            newBitmap.Save(Server.MapPath("~/Img/" + fileName), ImageFormat.Jpeg);
            Image2.ImageUrl = "~/Img/" + fileName;
        }

        protected void Button4_Click(object sender, EventArgs e)
        {
            Bitmap bitmap = new Bitmap(Server.MapPath("~/Img/") + TextBox1.Text);
            PS ps = new PS();
            Bitmap newBitmap = ps.fun4(bitmap.Height, bitmap.Width, bitmap);

            String fileName = DateTime.Now.ToString("yyyyMMddhhmmss") + "4.jpg";
            newBitmap.Save(Server.MapPath("~/Img/" + fileName), ImageFormat.Jpeg);
            Image2.ImageUrl = "~/Img/" + fileName;

        }

        protected void Button5_Click(object sender, EventArgs e)
        {
            Bitmap bitmap = new Bitmap(Server.MapPath("~/Img/") + TextBox1.Text);
            PS ps = new PS();
            Bitmap newBitmap = ps.fun5(bitmap.Height, bitmap.Width, bitmap);
            
            String fileName = DateTime.Now.ToString("yyyyMMddhhmmss") + "5.jpg";
            newBitmap.Save(Server.MapPath("~/Img/" + fileName), ImageFormat.Jpeg);
            Image2.ImageUrl = "~/Img/" + fileName;

        }

        protected void Button6_Click(object sender, EventArgs e)
        {
            Bitmap bitmap = new Bitmap(Server.MapPath("~/Img/") + TextBox1.Text);
            PS ps = new PS();
            Bitmap newBitmap = ps.fun6(bitmap.Height, bitmap.Width, bitmap);

            String fileName = DateTime.Now.ToString("yyyyMMddhhmmss") + "6.jpg";
            newBitmap.Save(Server.MapPath("~/Img/" + fileName), ImageFormat.Jpeg);
            Image2.ImageUrl = "~/Img/" + fileName;
        }

        protected void Button7_Click(object sender, EventArgs e)
        {
            string FileName = FileUpload1.PostedFile.FileName;
            string file_str = "文件名称：" + FileName + "<br>";
            file_str = "文件类型：" + FileUpload1.PostedFile.ContentType + "<br>";
            file_str = "文件长度：" + FileUpload1.PostedFile.ContentLength.ToString() + "KB<br>";
            //上传文件到服务器 
            FileName = FileName.Substring(FileName.LastIndexOf("\\") + 1);// 取出文件名的路径（不包括文件的名称） 

            string upload_file = Server.MapPath("~/Img/") + FileName;//取出服务器虚拟路径,存储上传文件 

            FileUpload1.PostedFile.SaveAs(upload_file);//开始上传文件 
            Label1.Text = file_str + "上传文件成功";
            Image1.ImageUrl = "../Img/" + FileName;
            TextBox1.Text = FileName;
        }

        protected void Quit_Click(object sender, EventArgs e)
        {
            Session.Clear();
            Response.Redirect("Index.aspx");
        }
      
    }
}